import Vue from 'vue'
// v-clickForbidden: 防止按钮多次点击
Vue.directive('clickForbidden', {
  bind(e) {
    let forbidClick = null
    const el = e
    let timer = null
    forbidClick = () => {
      // store.commit('app/SET_LOADING', true)
      el.disabled = true
      el.classList.add('is-disabled')
      timer = setInterval(() => {
        if (window.currentResq.done) {
          clearInterval(timer)
          el.disabled = false
          el.classList.remove('is-disabled')
        }
      }, 1000)
    }
    el.addEventListener('click', forbidClick)
  }
})
